from django.db import models
from datetime import datetime    
from django.template.defaultfilters import slugify

STATUS_CHOICES = (
    ('ENABLED', 'ENABLED'),
    ('DISABLED', 'DISABLED'),)
    
class Pages(models.Model):
    slug = models.SlugField(help_text='used for SEO',max_length=220)
    title = models.CharField(max_length=220)
    details=models.TextField()
    added_date = models.DateField(auto_now_add=True)
    status=models.CharField(max_length=8,choices=STATUS_CHOICES,default='ENABLED',null=False)
    notes=models.TextField(null=True,blank=True)
    def __str__(self):
        return self.title
    def save(self):
        super(Pages, self).save()
        #date = datetime.datetime.today()
        #self.slug = '%i/%i/%i/%i-%s' % (date.year, date.month, date.day, self.id, slugify(self.title)
        self.slug = slugify(self.title)
        super(Pages, self).save()